package part_II;
import java.math.BigDecimal;

import environment.Direction;
import environment.Dungeon;
import environment.Position;
import environment.Square;
import environment.borders.Border;
import environment.borders.Door;
import environment.borders.Wall;

import temperature.Temperature;
import temperature.TemperatureUnit;


/**
 * Dit is GEEEEEN testklasse, eerder een hoofdprogramma ter test...
 *
 */
public class TestAssociations {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		test1();
		
		test2();
		
		test3();
	}
	
	private static void test1(){
		Square square1 = new Square();
		Square square2 = new Square(Temperature.CELSIUS_1, BigDecimal.TEN, Direction.NORTH, Direction.EAST);
		Door door1 = new Door(square1, Direction.NORTH, false);
		door1.interact();
		System.out.println("Before Termination: ");
		System.out.println(square1);
		System.out.println(door1);
		System.out.println(square2);
		System.out.println(square2.getBorders());
		
		square2.terminate();
		door1.terminate();
		System.out.println();
		System.out.println();
		System.out.println("Termination: ");
		System.out.println(square2);
		System.out.println(square2.getBorders());
		System.out.println(door1);
		System.out.println(door1.getBorderedSquares());
		square1.getBorderAt(Direction.FLOOR).terminate();
		System.out.println(square1);
		
		Square square3 = new Square(Temperature.CELSIUS_1, BigDecimal.TEN, Direction.NORTH, Direction.EAST);
		Door door2 = new Door(square3, Direction.EAST, false);
		Square square4 = new Square(Temperature.CELSIUS_0, BigDecimal.TEN, Direction.NORTH, Direction.EAST);
		door2.setBorderedSquare(square4, Direction.WEST);
		System.out.println();
		System.out.println();
		System.out.println("Border_DOOR: ");
		System.out.println(door2);
		System.out.println();
		System.out.println();
		System.out.println();
		System.out.println();
	}
	
	private static void test2(){
		Dungeon dungeon = new Dungeon();
		Square squareCentre = new Square(new Temperature(new BigDecimal(50), TemperatureUnit.CELSIUS), new BigDecimal(40), Direction.EAST);
		Door door1 = new Door(squareCentre, Direction.WEST, false);
		Square squareCeil = new Square(new Temperature(new BigDecimal(30), TemperatureUnit.CELSIUS), new BigDecimal(60),Direction.CEILING);
		Square squareEast = new Square(new Temperature(new BigDecimal(200), TemperatureUnit.CELSIUS), new BigDecimal(0));
		System.out.println("VOOR MERGING: ");
		System.out.println(squareCentre);
		System.out.println(squareCeil);
		System.out.println(squareEast);
		
		dungeon.setSquareOnPosition(squareCentre,new Position(0,1,0));
		dungeon.setSquareOnPosition(squareCeil, new Position(0,1,1));
		dungeon.setSquareOnPosition(squareEast, new Position(1,1,0));
		System.out.println();
		System.out.println();
		System.out.println("NA MERGING: ");
		System.out.println(new Position(0,1,0) + ": \n" + dungeon.getSquareOnPosition(new Position(0,1,0)));
		System.out.println(new Position(0,1,1) + ": \n" + dungeon.getSquareOnPosition(new Position(0,1,1)));
		System.out.println(new Position(1,1,0) + ": \n" + dungeon.getSquareOnPosition(new Position(1,1,0)));
		
		door1.interact();///////////////////////////TODO: MOET OPNIEUW MERGEN IN OMGEVING
		System.out.println();
		System.out.println();
		System.out.println("NA OPENEN VAN DEUR: ");
		System.out.println(new Position(0,1,0) + ": \n" + dungeon.getSquareOnPosition(new Position(0,1,0)));
		System.out.println(new Position(0,1,1) + ": \n" + dungeon.getSquareOnPosition(new Position(0,1,1)));
		System.out.println(new Position(1,1,0) + ": \n" + dungeon.getSquareOnPosition(new Position(1,1,0)));
		
		new Wall(squareCentre, Direction.FLOOR, false);
		System.out.println();
		System.out.println();
		System.out.println("NA Toevoegen muur: ");
		System.out.println(new Position(0,1,0) + ": \n" + dungeon.getSquareOnPosition(new Position(0,1,0)));
		System.out.println(new Position(0,1,1) + ": \n" + dungeon.getSquareOnPosition(new Position(0,1,1)));
		System.out.println(new Position(1,1,0) + ": \n" + dungeon.getSquareOnPosition(new Position(1,1,0)));
		System.out.println();
		System.out.println();
		System.out.println();
		System.out.println();
	}
	
	private static void test3(){
		Square square1 = new Square();
		Square square2 = new Square();
		Border wall1 = new Wall(square1, Direction.EAST, false);
		square2.setBorder(wall1, Direction.EAST);
		System.out.println(square1.getBorderAt(Direction.WEST));
		System.out.println(square1);
		System.out.println(square2);
	}
}
